Skip to contentSkip to conversation

Change in openvpn[master]: add building of openvpnsrvmsg.dll from eventmsg.mc to autoconf/mingw ...

Openvpn-devel In review cron2 (Code Review) 2 participants 15 messages Sep 18, 2025 – Sep 19, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1758178873000.I071e8190dac28f429257b8af1c6f9e68f8896bc0@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email

to review the following change.

Change subject: add building of openvpnsrvmsg.dll from eventmsg.mc to autoconf/mingw builds
......................................................................

add building of openvpnsrvmsg.dll from eventmsg.mc to autoconf/mingw builds

commit 06919a60ae61 introduces .mc files that need to be compiled to .h and .bin by the windows "mc.exe" tool, and from there into a new .dll

Add logic to configure.ac to find the "windmc" binary in the linux or mingw variants, add rules to src/openvpnserv/Makefile.am so make knows what to do.

Libtool is getting in the way when "openvpnsrvmsg.dll" is created as anything listed in ...BIN or ...LIB, so decare it as "DATA" and make the necessary rules explicit.

See also:
https://learn.microsoft.com/en-us/cpp/build/creating-a-resource-only-dll?view=msvc-170

Change-Id I071e8190dac28f429257b8af1c6f9e68f8896bc0

---
M configure.ac
M src/openvpnserv/Makefile.am

2 files changed, 14 insertions(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/97/1197/1

configure.ac +1 -0
index 7059871..38b14a1 100644
@@ -441,6 +441,7 @@
 AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool])
 AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
 AC_DEFINE_UNQUOTED([SYSTEMD_ASK_PASSWORD_PATH], ["$SYSTEMD_ASK_PASSWORD"], [Path to systemd-ask-password tool])
+AC_CHECK_TOOLS([WINDMC], [windmc mc.exe],[no])
 
 #
 #  man page generation - based on python-docutils
src/openvpnserv/Makefile.am +13 -0
index ef5f3f3..e66ece9 100644
@@ -28,6 +28,8 @@
 openvpnserv_LDADD = \
 	-ladvapi32 -luserenv -liphlpapi -lfwpuclnt -lrpcrt4 \
 	-lshlwapi -lnetapi32 -lws2_32 -lntdll -lole32
+noinst_DATA = \
+	MSG00409.bin eventmsg.h eventmsg.rc openvpnservmsg.dll
 endif
 
 openvpnserv_SOURCES = \
@@ -37,3 +39,14 @@
 	validate.c validate.h \
 	$(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \
 	openvpnserv_resources.rc
+
+openvpnservmsg.dll: eventmsg.o
+	$(CC) -shared -Wl,--entry=0 -nostdlib -nostartfiles -o openvpnservmsg.dll eventmsg.o
+
+eventmsg.o: eventmsg.rc
+
+BUILT_SOURCES = \
+	eventmsg.h
+
+eventmsg.h: eventmsg.mc
+	$(WINDMC) -U eventmsg.mc

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I071e8190dac28f429257b8af1c6f9e68f8896bc0
Gerrit-Change-Number: 1197
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email

to look at the new patch set (#2).

Change subject: add building of openvpnsrvmsg.dll from eventmsg.mc to autoconf/mingw builds
......................................................................

add building of openvpnsrvmsg.dll from eventmsg.mc to autoconf/mingw builds

commit 06919a60ae61 introduces .mc files that need to be compiled to .h and .bin by the windows "mc.exe" tool, and from there into a new .dll

Add logic to configure.ac to find the "windmc" binary in the linux or mingw variants, add rules to src/openvpnserv/Makefile.am so make knows what to do.

Libtool is getting in the way when "openvpnsrvmsg.dll" is created as anything listed in ...BIN or ...LIB, so decare it as "DATA" and make the necessary rules explicit.

See also:
https://learn.microsoft.com/en-us/cpp/build/creating-a-resource-only-dll?view=msvc-170

Change-Id I071e8190dac28f429257b8af1c6f9e68f8896bc0

---
M configure.ac
M src/openvpnserv/Makefile.am

2 files changed, 13 insertions(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/97/1197/2

configure.ac +1 -0
index 7059871..38b14a1 100644
@@ -441,6 +441,7 @@
 AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool])
 AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
 AC_DEFINE_UNQUOTED([SYSTEMD_ASK_PASSWORD_PATH], ["$SYSTEMD_ASK_PASSWORD"], [Path to systemd-ask-password tool])
+AC_CHECK_TOOLS([WINDMC], [windmc mc.exe],[no])
 
 #
 #  man page generation - based on python-docutils
src/openvpnserv/Makefile.am +12 -0
index ef5f3f3..d475186 100644
@@ -28,6 +28,10 @@
 openvpnserv_LDADD = \
 	-ladvapi32 -luserenv -liphlpapi -lfwpuclnt -lrpcrt4 \
 	-lshlwapi -lnetapi32 -lws2_32 -lntdll -lole32
+noinst_DATA = \
+	MSG00409.bin eventmsg.h eventmsg.rc openvpnservmsg.dll
+BUILT_SOURCES = \
+	eventmsg.h
 endif
 
 openvpnserv_SOURCES = \
@@ -37,3 +41,11 @@
 	validate.c validate.h \
 	$(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \
 	openvpnserv_resources.rc
+
+openvpnservmsg.dll: eventmsg.o
+	$(CC) -shared -Wl,--entry=0 -nostdlib -nostartfiles -o openvpnservmsg.dll eventmsg.o
+
+eventmsg.o: eventmsg.rc
+
+eventmsg.h: eventmsg.mc
+	$(WINDMC) -U eventmsg.mc

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I071e8190dac28f429257b8af1c6f9e68f8896bc0
Gerrit-Change-Number: 1197
Gerrit-PatchSet: 2
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2, plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email )

Change subject: add building of openvpnsrvmsg.dll from eventmsg.mc to autoconf/mingw builds
......................................................................

Patch Set 2: Code-Review-1

(3 comments)

File src/openvpnserv/Makefile.am:

http://gerrit.openvpn.net/c/openvpn/+/1197/comment/504cb947_ee947437 :
PS2, Line 32: MSG00409.bin eventmsg.h eventmsg.rc openvpnservmsg.dll
Is it intentional that openvpnservmsg.dll is in noinst? Shouldn't it be installed?

http://gerrit.openvpn.net/c/openvpn/+/1197/comment/51bca724_b7505ca0 :
PS2, Line 46: $(CC) -shared -Wl,--entry=0 -nostdlib -nostartfiles -o openvpnservmsg.dll eventmsg.o
This looks like it might fail with out-of-tree builds. Can you please verify that it works. As a nitpick I would also recommend using $@ and $<

http://gerrit.openvpn.net/c/openvpn/+/1197/comment/8d382386_4d9818d6 :
PS2, Line 51: $(WINDMC) -U eventmsg.mc
same concerns here

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I071e8190dac28f429257b8af1c6f9e68f8896bc0
Gerrit-Change-Number: 1197
Gerrit-PatchSet: 2
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Thu, 18 Sep 2025 09:59:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#4 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, plaisthos.

Hello flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email

to look at the new patch set (#3).

The following approvals got outdated and were removed:
Code-Review-1 by flichtenheld

Change subject: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds
......................................................................

fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

commit 06919a60ae61 introduces .mc files that need to be compiled to .h and .bin by the windows "mc.exe" tool, and from there into a new .dll. This worked for MSVC builds, did nothing for cmake/mingw builds, and broke compilation on autoconf/mingw builds.

This patch consists of two parts:

1. add building of openvpnsrvmsg.dll to autoconf/mingw builds

Add logic to configure.ac to find the "windmc" binary in the linux or mingw variants, add rules to src/openvpnserv/Makefile.am so make knows what to do.

Libtool is getting in the way when "openvpnsrvmsg.dll" is created as anything listed in ...BIN or ...LIB, so decare it as "DATA" and make the necessary rules explicit.

2. fix building of openvpnsrvmsg.dll on cmake/mingw builds

Fix "find_program()" invocation to avoid using "midnight commander" binary (mc) on Linux (called "windmc" there).

Change from "-Wl,--noentry" to linker invocation that works.

See also:
https://learn.microsoft.com/en-us/cpp/build/creating-a-resource-only-dll?view=msvc-170

Change-Id I071e8190dac28f429257b8af1c6f9e68f8896bc0

---
M configure.ac
M src/openvpnserv/CMakeLists.txt
M src/openvpnserv/Makefile.am

3 files changed, 22 insertions(+), 4 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/97/1197/3

configure.ac +1 -0
index 7059871..38b14a1 100644
@@ -441,6 +441,7 @@
 AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool])
 AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
 AC_DEFINE_UNQUOTED([SYSTEMD_ASK_PASSWORD_PATH], ["$SYSTEMD_ASK_PASSWORD"], [Path to systemd-ask-password tool])
+AC_CHECK_TOOLS([WINDMC], [windmc mc.exe],[no])
 
 #
 #  man page generation - based on python-docutils
src/openvpnserv/CMakeLists.txt +9 -4
index 82099f1..4496bae 100644
@@ -41,7 +41,7 @@
 file(MAKE_DIRECTORY ${MC_GEN_DIR})
 set(MC_FILE ${CMAKE_CURRENT_SOURCE_DIR}/eventmsg.mc)
 
-find_program(MC_COMPILER NAMES mc mc.exe x86_64-w64-mingw32-windmc i686-w64-mingw32-windmc windmc)
+find_program(MC_COMPILER NAMES mc.exe x86_64-w64-mingw32-windmc i686-w64-mingw32-windmc windmc)
 
 if (NOT MC_COMPILER)
     message(FATAL_ERROR "No message compiler found.")
@@ -58,12 +58,17 @@
 add_custom_target(msg_mc_gen ALL DEPENDS ${MC_GEN_DIR}/eventmsg.rc ${MC_GEN_DIR}/eventmsg.h)
 
 add_library(openvpnservmsg SHARED ${MC_GEN_DIR}/eventmsg.rc)
+add_dependencies(openvpnservmsg msg_mc_gen)
 
 if (MSVC)
-    set_target_properties(openvpnservmsg PROPERTIES LINK_FLAGS "/NOENTRY")
+    set_target_properties(openvpnservmsg PRIVATE "/NOENTRY")
 else()
-    target_link_options(openvpnservmsg PRIVATE "-Wl,--no-entry")
+    set_target_properties(openvpnservmsg PROPERTIES LINKER_LANGUAGE C OUTPUT_NAME "openvpnservmsg")
+    target_link_options(openvpnservmsg PRIVATE
+        -Wl,--entry=0
+        -nostdlib
+        -nostartfiles
+    )
 endif()
 
-add_dependencies(openvpnservmsg msg_mc_gen)
 add_dependencies(openvpnserv msg_mc_gen)
src/openvpnserv/Makefile.am +12 -0
index ef5f3f3..a27fbbf 100644
@@ -28,6 +28,10 @@
 openvpnserv_LDADD = \
 	-ladvapi32 -luserenv -liphlpapi -lfwpuclnt -lrpcrt4 \
 	-lshlwapi -lnetapi32 -lws2_32 -lntdll -lole32
+noinst_DATA = \
+	MSG00409.bin eventmsg.h eventmsg.rc openvpnservmsg.dll
+BUILT_SOURCES = \
+	eventmsg.h
 endif
 
 openvpnserv_SOURCES = \
@@ -37,3 +41,11 @@
 	validate.c validate.h \
 	$(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \
 	openvpnserv_resources.rc
+
+openvpnservmsg.dll: eventmsg.o
+	$(CC) -shared -Wl,--entry=0 -nostdlib -nostartfiles -o $@ $<
+
+eventmsg.o: eventmsg.rc
+
+eventmsg.h: eventmsg.mc
+	$(WINDMC) -U $<

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I071e8190dac28f429257b8af1c6f9e68f8896bc0
Gerrit-Change-Number: 1197
Gerrit-PatchSet: 3
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#5 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, plaisthos.

stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email )

Change subject: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds
......................................................................

Patch Set 3: Code-Review-2

(1 comment)

File src/openvpnserv/CMakeLists.txt:

http://gerrit.openvpn.net/c/openvpn/+/1197/comment/f97cb62c_55af1224 :
PS3, Line 64: set_target_properties(openvpnservmsg PRIVATE "/NOENTRY")
My bad, this should be set_target_properties(openvpnservmsg PROPERTIES LINK_FLAGS "/NOENTRY") - basically same as before

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I071e8190dac28f429257b8af1c6f9e68f8896bc0
Gerrit-Change-Number: 1197
Gerrit-PatchSet: 3
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 18 Sep 2025 12:58:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#6 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, plaisthos.

Hello flichtenheld, plaisthos, stipa,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email

to look at the new patch set (#4).

Change subject: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds
......................................................................

fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

commit 06919a60ae61 introduces .mc files that need to be compiled to .h and .bin by the windows "mc.exe" tool, and from there into a new .dll. This worked for MSVC builds, did nothing for cmake/mingw builds, and broke compilation on autoconf/mingw builds.

This patch consists of two parts:

1. add building of openvpnsrvmsg.dll to autoconf/mingw builds

Add logic to configure.ac to find the "windmc" binary in the linux or mingw variants, add rules to src/openvpnserv/Makefile.am so make knows what to do.

Libtool is getting in the way when "openvpnsrvmsg.dll" is created as anything listed in ...BIN or ...LIB, so decare it as "DATA" and make the necessary rules explicit.

2. fix building of openvpnsrvmsg.dll on cmake/mingw builds

Fix "find_program()" invocation to avoid using "midnight commander" binary (mc) on Linux (called "windmc" there).

Change from "-Wl,--noentry" to linker invocation that works.

See also:
https://learn.microsoft.com/en-us/cpp/build/creating-a-resource-only-dll?view=msvc-170

Change-Id I071e8190dac28f429257b8af1c6f9e68f8896bc0

---
M configure.ac
M src/openvpnserv/CMakeLists.txt
M src/openvpnserv/Makefile.am

3 files changed, 21 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/97/1197/4

configure.ac +1 -0
index 7059871..38b14a1 100644
@@ -441,6 +441,7 @@
 AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool])
 AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
 AC_DEFINE_UNQUOTED([SYSTEMD_ASK_PASSWORD_PATH], ["$SYSTEMD_ASK_PASSWORD"], [Path to systemd-ask-password tool])
+AC_CHECK_TOOLS([WINDMC], [windmc mc.exe],[no])
 
 #
 #  man page generation - based on python-docutils
src/openvpnserv/CMakeLists.txt +8 -3
index 82099f1..340b904 100644
@@ -41,7 +41,7 @@
 file(MAKE_DIRECTORY ${MC_GEN_DIR})
 set(MC_FILE ${CMAKE_CURRENT_SOURCE_DIR}/eventmsg.mc)
 
-find_program(MC_COMPILER NAMES mc mc.exe x86_64-w64-mingw32-windmc i686-w64-mingw32-windmc windmc)
+find_program(MC_COMPILER NAMES mc.exe x86_64-w64-mingw32-windmc i686-w64-mingw32-windmc windmc)
 
 if (NOT MC_COMPILER)
     message(FATAL_ERROR "No message compiler found.")
@@ -58,12 +58,17 @@
 add_custom_target(msg_mc_gen ALL DEPENDS ${MC_GEN_DIR}/eventmsg.rc ${MC_GEN_DIR}/eventmsg.h)
 
 add_library(openvpnservmsg SHARED ${MC_GEN_DIR}/eventmsg.rc)
+add_dependencies(openvpnservmsg msg_mc_gen)
 
 if (MSVC)
     set_target_properties(openvpnservmsg PROPERTIES LINK_FLAGS "/NOENTRY")
 else()
-    target_link_options(openvpnservmsg PRIVATE "-Wl,--no-entry")
+    set_target_properties(openvpnservmsg PROPERTIES LINKER_LANGUAGE C OUTPUT_NAME "openvpnservmsg")
+    target_link_options(openvpnservmsg PRIVATE
+        -Wl,--entry=0
+        -nostdlib
+        -nostartfiles
+    )
 endif()
 
-add_dependencies(openvpnservmsg msg_mc_gen)
 add_dependencies(openvpnserv msg_mc_gen)
src/openvpnserv/Makefile.am +12 -0
index ef5f3f3..a27fbbf 100644
@@ -28,6 +28,10 @@
 openvpnserv_LDADD = \
 	-ladvapi32 -luserenv -liphlpapi -lfwpuclnt -lrpcrt4 \
 	-lshlwapi -lnetapi32 -lws2_32 -lntdll -lole32
+noinst_DATA = \
+	MSG00409.bin eventmsg.h eventmsg.rc openvpnservmsg.dll
+BUILT_SOURCES = \
+	eventmsg.h
 endif
 
 openvpnserv_SOURCES = \
@@ -37,3 +41,11 @@
 	validate.c validate.h \
 	$(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \
 	openvpnserv_resources.rc
+
+openvpnservmsg.dll: eventmsg.o
+	$(CC) -shared -Wl,--entry=0 -nostdlib -nostartfiles -o $@ $<
+
+eventmsg.o: eventmsg.rc
+
+eventmsg.h: eventmsg.mc
+	$(WINDMC) -U $<

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I071e8190dac28f429257b8af1c6f9e68f8896bc0
Gerrit-Change-Number: 1197
Gerrit-PatchSet: 4
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#7 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, plaisthos.

stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email )

Change subject: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds
......................................................................

Patch Set 4: Code-Review+1

(1 comment)

Patchset:

PS4:
CMake changes look good - I checked with GHA that the DLL is generated for mingw and msvc - I downloaded the artifacts (there is a separate patch to include more files into mingw job artifacts) and checked that the file is indeed there.

autotools is a black magic for me so I leave it to Frank.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I071e8190dac28f429257b8af1c6f9e68f8896bc0
Gerrit-Change-Number: 1197
Gerrit-PatchSet: 4
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 18 Sep 2025 13:15:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#8 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

In reply to a message not in the archive

Attention is currently required from: cron2, plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email )

Change subject: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds
......................................................................

Patch Set 4:

(3 comments)

File src/openvpnserv/Makefile.am:

http://gerrit.openvpn.net/c/openvpn/+/1197/comment/b366bbb6_39e946fa :
PS2, Line 32: MSG00409.bin eventmsg.h eventmsg.rc openvpnservmsg.dll

Quoted 1 line

Is it intentional that `openvpnservmsg. […]

Acknowledged

http://gerrit.openvpn.net/c/openvpn/+/1197/comment/9357acc2_b468f24e :
PS2, Line 46: $(CC) -shared -Wl,--entry=0 -nostdlib -nostartfiles -o openvpnservmsg.dll eventmsg.o

Quoted 1 line

This looks like it might fail with out-of-tree builds. Can you please verify that it works. […]

Done

http://gerrit.openvpn.net/c/openvpn/+/1197/comment/0472f96c_f7c0a629 :
PS2, Line 51: $(WINDMC) -U eventmsg.mc

Quoted 1 line

same concerns here

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I071e8190dac28f429257b8af1c6f9e68f8896bc0
Gerrit-Change-Number: 1197
Gerrit-PatchSet: 4
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Thu, 18 Sep 2025 13:55:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Gerrit-MessageType: comment

#9 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

In reply to a message not in the archive

Attention is currently required from: plaisthos, stipa.

cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email )

Change subject: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds
......................................................................

Patch Set 4:

(1 comment)

File src/openvpnserv/CMakeLists.txt:

http://gerrit.openvpn.net/c/openvpn/+/1197/comment/873ee4aa_9d95209e :
PS3, Line 64: set_target_properties(openvpnservmsg PRIVATE "/NOENTRY")

Quoted 1 line

My bad, this should be set_target_properties(openvpnservmsg PROPERTIES LINK_FLAGS "/NOENTRY") - basi […]

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I071e8190dac28f429257b8af1c6f9e68f8896bc0
Gerrit-Change-Number: 1197
Gerrit-PatchSet: 4
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Thu, 18 Sep 2025 17:21:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: stipa <[email protected]...>
Gerrit-MessageType: comment

#10 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

In reply to a message not in the archive

Attention is currently required from: cron2, plaisthos, stipa.

selvanair has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email )

Change subject: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds
......................................................................

Patch Set 4:

(2 comments)

Patchset:

PS4:
Very nice.. cmake-mingw also works now.
The dlls built using autotools also work on Windows event viewer.

File src/openvpnserv/Makefile.am:

http://gerrit.openvpn.net/c/openvpn/+/1197/comment/fe997674_e9daf92f :
PS4, Line 46: $(CC) -shared -Wl,--entry=0 -nostdlib -nostartfiles -o $@ $<
Adhoc build of this dll is fine, but fwiw, here is my try to use libtool instead: https://github.com/selvanair/openvpn/commit/bc94c62ac66a377df49044842515351aa256adcd

The resulting dll is larger, but could be stripped as we do with other binaries.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I071e8190dac28f429257b8af1c6f9e68f8896bc0
Gerrit-Change-Number: 1197
Gerrit-PatchSet: 4
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: selvanair <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Thu, 18 Sep 2025 17:45:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

#11 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

In reply to a message not in the archive

Attention is currently required from: cron2, plaisthos, stipa.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email )

Change subject: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds
......................................................................

Patch Set 4: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I071e8190dac28f429257b8af1c6f9e68f8896bc0
Gerrit-Change-Number: 1197
Gerrit-PatchSet: 4
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: selvanair <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Fri, 19 Sep 2025 10:29:01 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#12 lore raw

PATCH v4 1/1 fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

In reply to a message not in the archive

commit 06919a60ae61 introduces .mc files that need to be compiled to .h and .bin by the windows "mc.exe" tool, and from there into a new .dll. This worked for MSVC builds, did nothing for cmake/mingw builds, and broke compilation on autoconf/mingw builds.

This patch consists of two parts:

1. add building of openvpnsrvmsg.dll to autoconf/mingw builds

Add logic to configure.ac to find the "windmc" binary in the linux or mingw variants, add rules to src/openvpnserv/Makefile.am so make knows what to do.

Libtool is getting in the way when "openvpnsrvmsg.dll" is created as anything listed in ...BIN or ...LIB, so decare it as "DATA" and make the necessary rules explicit.

2. fix building of openvpnsrvmsg.dll on cmake/mingw builds

Fix "find_program()" invocation to avoid using "midnight commander" binary (mc) on Linux (called "windmc" there).

Change from "-Wl,--noentry" to linker invocation that works.

See also:
https://learn.microsoft.com/en-us/cpp/build/creating-a-resource-only-dll?view=msvc-170

Change-Id I071e8190dac28f429257b8af1c6f9e68f8896bc0

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1197
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1197
This mail reflects revision 4 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>

configure.ac +1 -0
index 7059871..38b14a1 100644
@@ -441,6 +441,7 @@
 AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool])
 AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
 AC_DEFINE_UNQUOTED([SYSTEMD_ASK_PASSWORD_PATH], ["$SYSTEMD_ASK_PASSWORD"], [Path to systemd-ask-password tool])
+AC_CHECK_TOOLS([WINDMC], [windmc mc.exe],[no])
 
 #
 #  man page generation - based on python-docutils
src/openvpnserv/CMakeLists.txt +8 -3
index 82099f1..340b904 100644
@@ -41,7 +41,7 @@
 file(MAKE_DIRECTORY ${MC_GEN_DIR})
 set(MC_FILE ${CMAKE_CURRENT_SOURCE_DIR}/eventmsg.mc)
 
-find_program(MC_COMPILER NAMES mc mc.exe x86_64-w64-mingw32-windmc i686-w64-mingw32-windmc windmc)
+find_program(MC_COMPILER NAMES mc.exe x86_64-w64-mingw32-windmc i686-w64-mingw32-windmc windmc)
 
 if (NOT MC_COMPILER)
     message(FATAL_ERROR "No message compiler found.")
@@ -58,12 +58,17 @@
 add_custom_target(msg_mc_gen ALL DEPENDS ${MC_GEN_DIR}/eventmsg.rc ${MC_GEN_DIR}/eventmsg.h)
 
 add_library(openvpnservmsg SHARED ${MC_GEN_DIR}/eventmsg.rc)
+add_dependencies(openvpnservmsg msg_mc_gen)
 
 if (MSVC)
     set_target_properties(openvpnservmsg PROPERTIES LINK_FLAGS "/NOENTRY")
 else()
-    target_link_options(openvpnservmsg PRIVATE "-Wl,--no-entry")
+    set_target_properties(openvpnservmsg PROPERTIES LINKER_LANGUAGE C OUTPUT_NAME "openvpnservmsg")
+    target_link_options(openvpnservmsg PRIVATE
+        -Wl,--entry=0
+        -nostdlib
+        -nostartfiles
+    )
 endif()
 
-add_dependencies(openvpnservmsg msg_mc_gen)
 add_dependencies(openvpnserv msg_mc_gen)
src/openvpnserv/Makefile.am +12 -0
index ef5f3f3..a27fbbf 100644
@@ -28,6 +28,10 @@
 openvpnserv_LDADD = \
 	-ladvapi32 -luserenv -liphlpapi -lfwpuclnt -lrpcrt4 \
 	-lshlwapi -lnetapi32 -lws2_32 -lntdll -lole32
+noinst_DATA = \
+	MSG00409.bin eventmsg.h eventmsg.rc openvpnservmsg.dll
+BUILT_SOURCES = \
+	eventmsg.h
 endif
 
 openvpnserv_SOURCES = \
@@ -37,3 +41,11 @@
 	validate.c validate.h \
 	$(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \
 	openvpnserv_resources.rc
+
+openvpnservmsg.dll: eventmsg.o
+	$(CC) -shared -Wl,--entry=0 -nostdlib -nostartfiles -o $@ $<
+
+eventmsg.o: eventmsg.rc
+
+eventmsg.h: eventmsg.mc
+	$(WINDMC) -U $<
#13 lore raw

[Openvpn-devel] [PATCH applied] Re: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

As discussed in Gerrit, this might not be the most beautiful construct, but it works for cmake+mingw and for in- and out-of-tree autoconf+mingw builds - and this is all it needs to do (and unlike v1, it does not break "non WIN32" builds ;-) ).

I have tested this by building on an ubuntu 2204 and copying openvpnserv.exe and openvpnservmsg.exe to a Win10 machine "that had never seen the new event log code", registered the DLL, and event log works. Yay.

Lev has tested the cmake+mingw builds (and the cmake+MSVC builds, of course, that were also broken in v3).

Your patch has been applied to the master and release/2.6 branch (necessary to enable mingw building of 2.6 again).

commit 744a2bd556833cf5e65d737e1bcffd2cb89a6d2f (master) commit 9d89e750d3e07b401e042b5456dec5d1187e346f (release/2.6)

Author: Gert Doering
Date:   Fri Sep 19 13:24:19 2025 +0200
     fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Frank Lichtenheld <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1197
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg33083.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#14 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

In reply to a message not in the archive

Attention is currently required from: stipa.

Hello flichtenheld, plaisthos, stipa,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email

to look at the new patch set (#5).

The following approvals got outdated and were removed:
Code-Review+1 by stipa, Code-Review+2 by flichtenheld

Change subject: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds
......................................................................

fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

commit 06919a60ae61 introduces .mc files that need to be compiled to .h and .bin by the windows "mc.exe" tool, and from there into a new .dll. This worked for MSVC builds, did nothing for cmake/mingw builds, and broke compilation on autoconf/mingw builds.

This patch consists of two parts:

1. add building of openvpnsrvmsg.dll to autoconf/mingw builds

Add logic to configure.ac to find the "windmc" binary in the linux or mingw variants, add rules to src/openvpnserv/Makefile.am so make knows what to do.

Libtool is getting in the way when "openvpnsrvmsg.dll" is created as anything listed in ...BIN or ...LIB, so decare it as "DATA" and make the necessary rules explicit.

2. fix building of openvpnsrvmsg.dll on cmake/mingw builds

Fix "find_program()" invocation to avoid using "midnight commander" binary (mc) on Linux (called "windmc" there).

Change from "-Wl,--noentry" to linker invocation that works.

See also:
https://learn.microsoft.com/en-us/cpp/build/creating-a-resource-only-dll?view=msvc-170

Change-Id I071e8190dac28f429257b8af1c6f9e68f8896bc0

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1197
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33083.html

---
M configure.ac
M src/openvpnserv/CMakeLists.txt
M src/openvpnserv/Makefile.am

3 files changed, 21 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/97/1197/5

configure.ac +1 -0
index 7059871..38b14a1 100644
@@ -441,6 +441,7 @@
 AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool])
 AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
 AC_DEFINE_UNQUOTED([SYSTEMD_ASK_PASSWORD_PATH], ["$SYSTEMD_ASK_PASSWORD"], [Path to systemd-ask-password tool])
+AC_CHECK_TOOLS([WINDMC], [windmc mc.exe],[no])
 
 #
 #  man page generation - based on python-docutils
src/openvpnserv/CMakeLists.txt +8 -3
index 82099f1..340b904 100644
@@ -41,7 +41,7 @@
 file(MAKE_DIRECTORY ${MC_GEN_DIR})
 set(MC_FILE ${CMAKE_CURRENT_SOURCE_DIR}/eventmsg.mc)
 
-find_program(MC_COMPILER NAMES mc mc.exe x86_64-w64-mingw32-windmc i686-w64-mingw32-windmc windmc)
+find_program(MC_COMPILER NAMES mc.exe x86_64-w64-mingw32-windmc i686-w64-mingw32-windmc windmc)
 
 if (NOT MC_COMPILER)
     message(FATAL_ERROR "No message compiler found.")
@@ -58,12 +58,17 @@
 add_custom_target(msg_mc_gen ALL DEPENDS ${MC_GEN_DIR}/eventmsg.rc ${MC_GEN_DIR}/eventmsg.h)
 
 add_library(openvpnservmsg SHARED ${MC_GEN_DIR}/eventmsg.rc)
+add_dependencies(openvpnservmsg msg_mc_gen)
 
 if (MSVC)
     set_target_properties(openvpnservmsg PROPERTIES LINK_FLAGS "/NOENTRY")
 else()
-    target_link_options(openvpnservmsg PRIVATE "-Wl,--no-entry")
+    set_target_properties(openvpnservmsg PROPERTIES LINKER_LANGUAGE C OUTPUT_NAME "openvpnservmsg")
+    target_link_options(openvpnservmsg PRIVATE
+        -Wl,--entry=0
+        -nostdlib
+        -nostartfiles
+    )
 endif()
 
-add_dependencies(openvpnservmsg msg_mc_gen)
 add_dependencies(openvpnserv msg_mc_gen)
src/openvpnserv/Makefile.am +12 -0
index ef5f3f3..a27fbbf 100644
@@ -28,6 +28,10 @@
 openvpnserv_LDADD = \
 	-ladvapi32 -luserenv -liphlpapi -lfwpuclnt -lrpcrt4 \
 	-lshlwapi -lnetapi32 -lws2_32 -lntdll -lole32
+noinst_DATA = \
+	MSG00409.bin eventmsg.h eventmsg.rc openvpnservmsg.dll
+BUILT_SOURCES = \
+	eventmsg.h
 endif
 
 openvpnserv_SOURCES = \
@@ -37,3 +41,11 @@
 	validate.c validate.h \
 	$(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \
 	openvpnserv_resources.rc
+
+openvpnservmsg.dll: eventmsg.o
+	$(CC) -shared -Wl,--entry=0 -nostdlib -nostartfiles -o $@ $<
+
+eventmsg.o: eventmsg.rc
+
+eventmsg.h: eventmsg.mc
+	$(WINDMC) -U $<

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I071e8190dac28f429257b8af1c6f9e68f8896bc0
Gerrit-Change-Number: 1197
Gerrit-PatchSet: 5
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: selvanair <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-MessageType: newpatchset

#15 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

In reply to a message not in the archive

Attention is currently required from: stipa.

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email )

Change subject: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds
......................................................................

fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds

commit 06919a60ae61 introduces .mc files that need to be compiled to .h and .bin by the windows "mc.exe" tool, and from there into a new .dll. This worked for MSVC builds, did nothing for cmake/mingw builds, and broke compilation on autoconf/mingw builds.

This patch consists of two parts:

1. add building of openvpnsrvmsg.dll to autoconf/mingw builds

Add logic to configure.ac to find the "windmc" binary in the linux or mingw variants, add rules to src/openvpnserv/Makefile.am so make knows what to do.

Libtool is getting in the way when "openvpnsrvmsg.dll" is created as anything listed in ...BIN or ...LIB, so decare it as "DATA" and make the necessary rules explicit.

2. fix building of openvpnsrvmsg.dll on cmake/mingw builds

Fix "find_program()" invocation to avoid using "midnight commander" binary (mc) on Linux (called "windmc" there).

Change from "-Wl,--noentry" to linker invocation that works.

See also:
https://learn.microsoft.com/en-us/cpp/build/creating-a-resource-only-dll?view=msvc-170

Change-Id I071e8190dac28f429257b8af1c6f9e68f8896bc0

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1197
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33083.html

---
M configure.ac
M src/openvpnserv/CMakeLists.txt
M src/openvpnserv/Makefile.am

3 files changed, 21 insertions(+), 3 deletions(-)
configure.ac +1 -0
index 7059871..38b14a1 100644
@@ -441,6 +441,7 @@
 AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool])
 AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
 AC_DEFINE_UNQUOTED([SYSTEMD_ASK_PASSWORD_PATH], ["$SYSTEMD_ASK_PASSWORD"], [Path to systemd-ask-password tool])
+AC_CHECK_TOOLS([WINDMC], [windmc mc.exe],[no])
 
 #
 #  man page generation - based on python-docutils
src/openvpnserv/CMakeLists.txt +8 -3
index 82099f1..340b904 100644
@@ -41,7 +41,7 @@
 file(MAKE_DIRECTORY ${MC_GEN_DIR})
 set(MC_FILE ${CMAKE_CURRENT_SOURCE_DIR}/eventmsg.mc)
 
-find_program(MC_COMPILER NAMES mc mc.exe x86_64-w64-mingw32-windmc i686-w64-mingw32-windmc windmc)
+find_program(MC_COMPILER NAMES mc.exe x86_64-w64-mingw32-windmc i686-w64-mingw32-windmc windmc)
 
 if (NOT MC_COMPILER)
     message(FATAL_ERROR "No message compiler found.")
@@ -58,12 +58,17 @@
 add_custom_target(msg_mc_gen ALL DEPENDS ${MC_GEN_DIR}/eventmsg.rc ${MC_GEN_DIR}/eventmsg.h)
 
 add_library(openvpnservmsg SHARED ${MC_GEN_DIR}/eventmsg.rc)
+add_dependencies(openvpnservmsg msg_mc_gen)
 
 if (MSVC)
     set_target_properties(openvpnservmsg PROPERTIES LINK_FLAGS "/NOENTRY")
 else()
-    target_link_options(openvpnservmsg PRIVATE "-Wl,--no-entry")
+    set_target_properties(openvpnservmsg PROPERTIES LINKER_LANGUAGE C OUTPUT_NAME "openvpnservmsg")
+    target_link_options(openvpnservmsg PRIVATE
+        -Wl,--entry=0
+        -nostdlib
+        -nostartfiles
+    )
 endif()
 
-add_dependencies(openvpnservmsg msg_mc_gen)
 add_dependencies(openvpnserv msg_mc_gen)
src/openvpnserv/Makefile.am +12 -0
index ef5f3f3..a27fbbf 100644
@@ -28,6 +28,10 @@
 openvpnserv_LDADD = \
 	-ladvapi32 -luserenv -liphlpapi -lfwpuclnt -lrpcrt4 \
 	-lshlwapi -lnetapi32 -lws2_32 -lntdll -lole32
+noinst_DATA = \
+	MSG00409.bin eventmsg.h eventmsg.rc openvpnservmsg.dll
+BUILT_SOURCES = \
+	eventmsg.h
 endif
 
 openvpnserv_SOURCES = \
@@ -37,3 +41,11 @@
 	validate.c validate.h \
 	$(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \
 	openvpnserv_resources.rc
+
+openvpnservmsg.dll: eventmsg.o
+	$(CC) -shared -Wl,--entry=0 -nostdlib -nostartfiles -o $@ $<
+
+eventmsg.o: eventmsg.rc
+
+eventmsg.h: eventmsg.mc
+	$(WINDMC) -U $<

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1197?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I071e8190dac28f429257b8af1c6f9e68f8896bc0
Gerrit-Change-Number: 1197
Gerrit-PatchSet: 5
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: selvanair <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-MessageType: merged